<%--
  Created by IntelliJ IDEA.
  User: 12459
  Date: 2024/11/11
  Time: 11:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form>
    <c:choose>
        <c:when test="${provider.id!=null}">
            <input type="hidden" value="modify" name="method">
            <input type="text" value="${provider.id}" name="id" readonly><br>
        </c:when>
        <c:otherwise>
            <input type="hidden" value="save" name="method">
        </c:otherwise>
    </c:choose>
    供货商名称:<input type="text" value="${provider.proName}" name="proName"><br>
    供货商编码:<input type="text" value="${provider.proCode}" name="proCode"><br>
    供货人:<input type="text" value="${provider.proContact}" name="proContact"><br>
    电话:<input type="text" value="${provider.proPhone}" name="proPhone"><br>
    供货商介绍:<br><textarea name="proDesc" cols="100" rows="10" placeholder="${provider.proDesc}"></textarea><br>
    <input type="button" value="提交">
</form>
</body>
<script src="/js/jquery-3.7.1.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("input[type='button']").click(function () {
            var formData = $("form").serialize();
            $.ajax({
                url:"/provider/"+$("input[type='hidden']").val(),
                type:"post",
                data:formData,
                dataType:"json",
                success:function (data) {
                    alert(data.message);
                    if(data.code === 200){
                        location.href = "/provider/findByPage"
                    }
                }
            })
        })
    })

</script>
</html>
